<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="ftm" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: holle
  Date: 2020/6/13
  Time: 16:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" pageEncoding="utf-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">
    <title>购买页面</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <script type="text/javascript" src="<%=basePath%>script/jquery-1.11.0.js"></script>
    <link
            href="<%=basePath%>static/bootstrap-3.3.7-dist/css/bootstrap.min.css"
            rel="stylesheet">
    <script type="text/javascript"
            src="<%=basePath%>static/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <script type="text/javascript">
		$(function () {
			//找到省份元素
            /*var o= $("#province").val();
            alert(o)*/
            //$("#province").live("change",function(){.....})
			/*$("#province").change(function () {
				var  pid = $(this).val();*/

				$.post("account/findAccout",null,function (data,status) {
					//先清空元素
					$("#city").html("<option value=''>-请选择-");

					$(data).each(function (index ,c) {
						$("#city").append("<option value='"+c.accid+"' >"+c.accid +"---余额:"+c.balance)
					})
				},"json");
			/*})*/
             $("#num").change(function () {
	              var  quanVal = $.trim(this.value);
	              var kuncun = $("#kucun").val();
                 // alert(kuncun)
	              var  flag = false;
				  var  reg =/^\d+$/g;
				  var quantity = -1;
				  if (reg.test(quanVal)){
				  	quantity = parseInt(quanVal);
				  	if (quantity>=0 && quantity<=kuncun){
				  		flag = true;
                    }
                  }
				  if (!flag){
				  	alert("您输入的数量不合法！");
					  $(this).val($(this).attr("title"));
					 // $.trim(this.value)==1;
					  return;
                  }
			 })

		})
    </script>
</head>
<body>
<center>
    <h2>图书购买页面</h2>
    <div style="width: 143px;height: 143px;">
        <img src="${book.img_path}" width="200px" height="300px" class="img-circle">
    </div>

    <p/>
    <form class="form-horizontal" role="form" style="width: 600px" method="post" action="account/updateStoban">
        <input id="bookid" name="bookid" type="hidden" value="${book.bookid}"/>
        <div class="form-group">
            <label class="col-sm-2 control-label">图书名字</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="firstname" placeholder="请输入名字" name="name" value="${book.book_name}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-2 control-label">图书出版社</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" name="score" placeholder="请输入成绩"  value="${book.public_dept}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">图书价格</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" name="price" placeholder="请输入地址" value="${book.book_price}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">出版日期</label>
            <div class="col-sm-10">
                <input type="text" class="form-control"placeholder="请输入生日" name="bitthday"  value="<ftm:formatDate value="${book.public_date}" pattern="yyyy-MM-dd" />">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">作者</label>
            <div class="col-sm-10">
                <input type="text" class="form-control"  placeholder="请输入入学日期" value="${book.book_auth}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">填写发货地址</label>
            <div class="col-sm-12">
                <TEXTAREA name=description cols="40" rows="5"></TEXTAREA>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label" >库存</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="kucun" placeholder="请输入入学日期" value="${book.storehouse.book_count}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">支付方式</label>
            <div class="col-sm-10">
             支付人：<select id="province">
                    <option selected value="${sessionScope.user.userid}">${sessionScope.user.realname}</option>
                </select>
                    选择支付账户：<select  id="city" name="accid">
                        <option value="">--请选择--</option>
                    </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">购买数量</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" title="1"  placeholder="购买数量" name="num" id="num">
            </div>
        </div>
        <input  class="btn btn-primary" type="submit" value="付款"/>

    </form>
</center>
</body>
</html>

